# Maintainer: Balló György <ballogyor+arch at gmail dot com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - drop dependency on libxnvctrl (nvidia-settings)

pkgname=sensors-applet
pkgver=3.0.0
pkgrel=4
epoch=1
pkgdesc='Applet for GNOME Panel to display readings from hardware sensors'
arch=('x86_64')
url='https://sensors-applet.sourceforge.net/'
license=('GPL-2.0-or-later')
depends=('cairo' 'dconf' 'gdk-pixbuf2' 'glib2' 'glibc' 'gnome-panel' 'gtk3' 'hicolor-icon-theme'
         'libx11' 'lm_sensors')
makedepends=('git' 'intltool' 'yelp-tools')
optdepends=('hddtemp: get HDD temperatures'
            'udisks2: get HDD temperatures')
source=("$pkgname::git+https://git.code.sf.net/p/sensors-applet/code#tag=$pkgver"
        'port-to-libgnome-panel.patch'
        'fix-crash-destroying-active-sensor.patch'
        'include-unistd.h.patch'
        'drop-gnome-common.patch'
        'sensors-applet-3.0.0-udisks2-plugin.patch')
b2sums=('d47a432fca9389d000a2ed2a0c8e4adea8ae3293efb8b06ae8ec95a61414954288838736bc52d6dc3449a73f9856acd8613b93e59c34b1ff0b5cbf27117a429d'
        'cf4bba7ab01623b9a0b1c80b364bef8414e25184e1ecc8e332f4280bb890d457b72a5c4f3a06f8e2e5bfc35a7f0a799251a9e1b31d8bb5620e95fa7c0edba1a1'
        '67f2fd1b99204fedc2a73142ac253c6c7bf73c915218b69cd99d9967825f986e74bf33568ce642d5debe00906674e0f5e30fd05938a6ba6f19d609a71cb34a5f'
        '6646ddbbeb2105b96a798755bec940878fd255f483463b6559b364a1158b4a027aa0375c295b92c2db10abca269a2cc5ed06554d1348b11c06bc78734d89e0eb'
        'c93fc3d3cc937331e7e264d27ebe2f1ec8d7323490bbcaaa63c75033fc4a49a75bf571dd4ae533309d934653fba77c28b0d22ba377549498bee0fb19d6d7ad1a'
        '9d50a46954b19a1bc9fe3350153020623313bea9f15f3997fbd92a0a4920c50bfdab6c0347b3f5eaf9fadb15998e982cd69dd9bdbb8f1e0e6f14465222ab2151')

prepare() {
  cd $pkgname

  # Various fixes from upstream
  git cherry-pick -n 9b8ca0e2e368c40fdfb64565e45eb1aa3cdeccf9..07284262768e3a7066da09845370d78526be6bc1

  # Port to libgnome-panel
  patch -Np1 -i ../port-to-libgnome-panel.patch

  # Fix crash destroying active sensor
  patch -Np1 -i ../fix-crash-destroying-active-sensor.patch

  # Fix build
  patch -Np1 -i ../include-unistd.h.patch

  # Remove usage of deprecated gnome-common
  patch -Np1 -i ../drop-gnome-common.patch

  # Port to udisks2
  patch -Np1 -i ../sensors-applet-3.0.0-udisks2-plugin.patch

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
